import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { cameraInfoVO, cameraInfoForm, cameraInfoQuery } from '@/api/security/camera/camera-info/types';

/**
 * 查询摄像头信息列表
 * @param query
 * @returns {*}
 */

export const listcameraInfo = (query?: cameraInfoQuery): AxiosPromise<cameraInfoVO[]> => {
  return request({
    url: '/camera/camera-info/list',
    method: 'get',
    params: query
  });
};

/**
 * 同步设备
 * @param query
 * @returns {*}
 */
export const equipmentSync = (query?: cameraInfoQuery): AxiosPromise<cameraInfoVO[]> => {
  return request({
    url: '/equipment/equipment-info/sync-camera',
    method: 'put',
    data: query
  });
};


/**
 * 查询摄像头信息详细
 * @param cameraInfoId
 */
export const getcameraInfo = (cameraInfoId: string | number): AxiosPromise<cameraInfoVO> => {
  return request({
    url: '/camera/camera-info/' + cameraInfoId,
    method: 'get'
  });
};

/**
 * 查询摄像头信息详细
 */
export const getCameraVideoUrl = (equipmentIds: string | number | Array<string | number>): AxiosPromise<cameraInfoVO> => {
  return request({
    url: '/camera/camera-info/video-url/' + equipmentIds,
    method: 'get'
  });
};

/**
 * 查询摄像头信息详细
 */
export const getVideoUrlByCameraId = (cameraId: string | number, startTime, endTime): AxiosPromise<cameraInfoVO> => {
  return request({
    url: '/camera/camera-info/get-video-url-by-camera-id/' + cameraId,
    method: 'get',
    params: { startTime: startTime, endTime: endTime }
  });
};

/**
 * 新增摄像头信息
 * @param data
 */
export const addcameraInfo = (data: cameraInfoForm) => {
  return request({
    url: '/camera/camera-info',
    method: 'post',
    data: data
  });
};

/**
 * 修改摄像头信息
 * @param data
 */
export const updatecameraInfo = (data: cameraInfoForm) => {
  return request({
    url: '/camera/camera-info',
    method: 'put',
    data: data
  });
};

/**
 * 删除摄像头信息
 * @param cameraInfoId
 */
export const delcameraInfo = (cameraInfoId: string | number | Array<string | number>) => {
  return request({
    url: '/camera/camera-info/' + cameraInfoId,
    method: 'delete'
  });
};

/**
 * 顶部统计
 */
export const equipmentstatistic = () => {
  return request({
    url: '/equipment/equipment-info/selectStatisticResult/camera',
    method: 'get'
  });
};
